<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>大奔农庄</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>    
</head>
<body>
	<div class="aui-content aui-margin-b-15">
		<form id="pwdForm">
		    <ul class="aui-list aui-form-list">
		        <li class="aui-list-item">
		            <div class="aui-list-item-inner">
		                <div class="aui-list-item-label">原密码：</div>
		                <div class="aui-list-item-input">
		                    <input type="password" id="oldpwd">
		                </div>
		            </div>
		        </li> <p class="height15"></p>
		        <li class="aui-list-item">
		            <div class="aui-list-item-inner">
		                <div class="aui-list-item-label">新密码： </div>
		                <div class="aui-list-item-input">
		                    <input type="password" id="newpwd">
		                </div>
		            </div>
		        </li> <p class="height15"></p>
		        <li class="aui-list-item">
		            <div class="aui-list-item-inner">
		                <div class="aui-list-item-label">确认新密码：</div>
		                <div class="aui-list-item-input">
		                    <input type="password" id="quepwd">
		                </div>
		            </div>
		        </li><p class="height15"></p>
		     </ul>
		 </form>    
     </div>
     <div class="aui-content-padded">
		 <p><div class="aui-btn aui-btn-block aui-btn-success aui-btn-sm" onclick="submit();">确认修改</div></p>
	 </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script>
var db_key = 'user',db_user;
apiready = function() {
    db_user = $api.getStorage(db_key);//获取用户信息
    myParam = api.pageParam;//获取参数

    $oldpwd = $api.byId("oldpwd");//旧密码
    $newpwd = $api.byId("newpwd");//新密码
    $quepwd = $api.byId("quepwd");//确认新密码
}

function submit() {
	var preg = new RegExp(/.{6}/);
    
    if ($oldpwd.value =="") {
        api.toast({msg: '旧密码不能为空！'});
        return false;
    }
    if ($newpwd.value =="") {
        api.toast({msg: '新密码不能为空！'});
        return false;
    }
    if(!preg.test($newpwd.value)) {
        api.toast({msg: '请输入最少6位密码'});
        return false;
    }
    if ($quepwd.value != $newpwd.value) {
        api.toast({msg: '两次密码输入不一致！'});
        return false;
    }
    api.showProgress();
    var useParam = {
    	rtk : RSapi.myrtk,
        mytoken : db_user.mytoken,
        orgpwd	: $oldpwd.value, 
        newpwd  : $newpwd.value,
    };
	//修改登录密码
	api.ajax({
        url: RSapi.base+RSapi.Mchgpwd,
        method: 'post',
        cache: false,
        timeout: 30,
        dataType: 'json',
        data: {values: useParam},
    },function(ret, err){ 
        if (err) { //alert(err.msg);return false;
            api.toast({msg:err.msg});
        }else if (ret.status) { 
            api.alert({msg:ret.info});
			api.closeWin();
        }else { 
            api.toast({msg:ret.info});
        }
        api.hideProgress();
    });
}
</script>
</html>